<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>Atomic Operations</title>
<meta name="generator" content="DocBook XSL Stylesheets V1.76.1">
<link rel="home" href="index.html" title="GLib Reference Manual">
<link rel="up" href="glib-fundamentals.html" title="GLib Fundamentals">
<link rel="prev" href="glib-Miscellaneous-Macros.html" title="Miscellaneous Macros">
<link rel="next" href="glib-core.html" title="GLib Core Application Support">
<meta name="generator" content="GTK-Doc V1.17 (XML mode)">
<link rel="stylesheet" href="style.css" type="text/css">
</head>
<body bgcolor="white" text="black" link="#0000FF" vlink="#840084" alink="#0000FF">
<table class="navigation" id="top" width="100%" summary="Navigation header" cellpadding="2" cellspacing="2">
<tr valign="middle">
<td><a accesskey="p" href="glib-Miscellaneous-Macros.html"><img src="left.png" width="24" height="24" border="0" alt="Prev"></a></td>
<td><a accesskey="u" href="glib-fundamentals.html"><img src="up.png" width="24" height="24" border="0" alt="Up"></a></td>
<td><a accesskey="h" href="index.html"><img src="home.png" width="24" height="24" border="0" alt="Home"></a></td>
<th width="100%" align="center">GLib Reference Manual</th>
<td><a accesskey="n" href="glib-core.html"><img src="right.png" width="24" height="24" border="0" alt="Next"></a></td>
</tr>
<tr><td colspan="5" class="shortcuts">
<a href="#glib-Atomic-Operations.synopsis" class="shortcut">Top</a>
                   | 
                  <a href="#glib-Atomic-Operations.description" class="shortcut">Description</a>
</td></tr>
</table>
<div class="refentry">
<a name="glib-Atomic-Operations"></a><div class="titlepage"></div>
<div class="refnamediv"><table width="100%"><tr>
<td valign="top">
<h2><span class="refentrytitle"><a name="glib-Atomic-Operations.top_of_page"></a>Atomic Operations</span></h2>
<p>Atomic Operations — basic atomic integer and pointer operations</p>
</td>
<td valign="top" align="right"></td>
</tr></table></div>
<div class="refsynopsisdiv">
<a name="glib-Atomic-Operations.synopsis"></a><h2>Synopsis</h2>
<pre class="synopsis">
#include &lt;glib.h&gt;

<a class="link" href="glib-Basic-Types.html#gint" title="gint"><span class="returnvalue">gint</span></a>                <a class="link" href="glib-Atomic-Operations.html#g-atomic-int-get" title="g_atomic_int_get ()">g_atomic_int_get</a>                    (<em class="parameter"><code>volatile <a class="link" href="glib-Basic-Types.html#gint" title="gint"><span class="type">gint</span></a> G_GNUC_MAY_ALIAS *atomic</code></em>);
<span class="returnvalue">void</span>                <a class="link" href="glib-Atomic-Operations.html#g-atomic-int-set" title="g_atomic_int_set ()">g_atomic_int_set</a>                    (<em class="parameter"><code>volatile <a class="link" href="glib-Basic-Types.html#gint" title="gint"><span class="type">gint</span></a> G_GNUC_MAY_ALIAS *atomic</code></em>,
                                                         <em class="parameter"><code><a class="link" href="glib-Basic-Types.html#gint" title="gint"><span class="type">gint</span></a> newval</code></em>);
<span class="returnvalue">void</span>                <a class="link" href="glib-Atomic-Operations.html#g-atomic-int-add" title="g_atomic_int_add ()">g_atomic_int_add</a>                    (<em class="parameter"><code>volatile <a class="link" href="glib-Basic-Types.html#gint" title="gint"><span class="type">gint</span></a> G_GNUC_MAY_ALIAS *atomic</code></em>,
                                                         <em class="parameter"><code><a class="link" href="glib-Basic-Types.html#gint" title="gint"><span class="type">gint</span></a> val</code></em>);
<a class="link" href="glib-Basic-Types.html#gint" title="gint"><span class="returnvalue">gint</span></a>                <a class="link" href="glib-Atomic-Operations.html#g-atomic-int-exchange-and-add" title="g_atomic_int_exchange_and_add ()">g_atomic_int_exchange_and_add</a>       (<em class="parameter"><code>volatile <a class="link" href="glib-Basic-Types.html#gint" title="gint"><span class="type">gint</span></a> G_GNUC_MAY_ALIAS *atomic</code></em>,
                                                         <em class="parameter"><code><a class="link" href="glib-Basic-Types.html#gint" title="gint"><span class="type">gint</span></a> val</code></em>);
<a class="link" href="glib-Basic-Types.html#gboolean" title="gboolean"><span class="returnvalue">gboolean</span></a>            <a class="link" href="glib-Atomic-Operations.html#g-atomic-int-compare-and-exchange" title="g_atomic_int_compare_and_exchange ()">g_atomic_int_compare_and_exchange</a>   (<em class="parameter"><code>volatile <a class="link" href="glib-Basic-Types.html#gint" title="gint"><span class="type">gint</span></a> G_GNUC_MAY_ALIAS *atomic</code></em>,
                                                         <em class="parameter"><code><a class="link" href="glib-Basic-Types.html#gint" title="gint"><span class="type">gint</span></a> oldval</code></em>,
                                                         <em class="parameter"><code><a class="link" href="glib-Basic-Types.html#gint" title="gint"><span class="type">gint</span></a> newval</code></em>);
<a class="link" href="glib-Basic-Types.html#gpointer" title="gpointer"><span class="returnvalue">gpointer</span></a>            <a class="link" href="glib-Atomic-Operations.html#g-atomic-pointer-get" title="g_atomic_pointer_get ()">g_atomic_pointer_get</a>                (<em class="parameter"><code>volatile <a class="link" href="glib-Basic-Types.html#gpointer" title="gpointer"><span class="type">gpointer</span></a> G_GNUC_MAY_ALIAS *atomic</code></em>);
<span class="returnvalue">void</span>                <a class="link" href="glib-Atomic-Operations.html#g-atomic-pointer-set" title="g_atomic_pointer_set ()">g_atomic_pointer_set</a>                (<em class="parameter"><code>volatile <a class="link" href="glib-Basic-Types.html#gpointer" title="gpointer"><span class="type">gpointer</span></a> G_GNUC_MAY_ALIAS *atomic</code></em>,
                                                         <em class="parameter"><code><a class="link" href="glib-Basic-Types.html#gpointer" title="gpointer"><span class="type">gpointer</span></a> newval</code></em>);
<a class="link" href="glib-Basic-Types.html#gboolean" title="gboolean"><span class="returnvalue">gboolean</span></a>            <a class="link" href="glib-Atomic-Operations.html#g-atomic-pointer-compare-and-exchange" title="g_atomic_pointer_compare_and_exchange ()">g_atomic_pointer_compare_and_exchange</a>
                                                        (<em class="parameter"><code>volatile <a class="link" href="glib-Basic-Types.html#gpointer" title="gpointer"><span class="type">gpointer</span></a> G_GNUC_MAY_ALIAS *atomic</code></em>,
                                                         <em class="parameter"><code><a class="link" href="glib-Basic-Types.html#gpointer" title="gpointer"><span class="type">gpointer</span></a> oldval</code></em>,
                                                         <em class="parameter"><code><a class="link" href="glib-Basic-Types.html#gpointer" title="gpointer"><span class="type">gpointer</span></a> newval</code></em>);
<span class="returnvalue">void</span>                <a class="link" href="glib-Atomic-Operations.html#g-atomic-int-inc" title="g_atomic_int_inc ()">g_atomic_int_inc</a>                    (<em class="parameter"><code><a class="link" href="glib-Basic-Types.html#gint" title="gint"><span class="type">gint</span></a> *atomic</code></em>);
<a class="link" href="glib-Basic-Types.html#gboolean" title="gboolean"><span class="returnvalue">gboolean</span></a>            <a class="link" href="glib-Atomic-Operations.html#g-atomic-int-dec-and-test" title="g_atomic_int_dec_and_test ()">g_atomic_int_dec_and_test</a>           (<em class="parameter"><code><a class="link" href="glib-Basic-Types.html#gint" title="gint"><span class="type">gint</span></a> *atomic</code></em>);
</pre>
</div>
<div class="refsect1">
<a name="glib-Atomic-Operations.description"></a><h2>Description</h2>
<p>
The following functions can be used to atomically access integers and
pointers. They are implemented as inline assembler function on most
platforms and use slower fall-backs otherwise. Using them can sometimes
save you from using a performance-expensive <a class="link" href="glib-Threads.html#GMutex" title="GMutex"><span class="type">GMutex</span></a> to protect the
integer or pointer.
</p>
<p>
The most important usage is reference counting. Using
<a class="link" href="glib-Atomic-Operations.html#g-atomic-int-inc" title="g_atomic_int_inc ()"><code class="function">g_atomic_int_inc()</code></a> and <a class="link" href="glib-Atomic-Operations.html#g-atomic-int-dec-and-test" title="g_atomic_int_dec_and_test ()"><code class="function">g_atomic_int_dec_and_test()</code></a> makes reference
counting a very fast operation.
</p>
<p>
</p>
<div class="note" style="margin-left: 0.5in; margin-right: 0.5in;">
<h3 class="title">Note</h3>
<p>You must not directly read integers or pointers concurrently
accessed by multiple threads, but use the atomic accessor functions
instead. That is, always use <a class="link" href="glib-Atomic-Operations.html#g-atomic-int-get" title="g_atomic_int_get ()"><code class="function">g_atomic_int_get()</code></a> and <a class="link" href="glib-Atomic-Operations.html#g-atomic-pointer-get" title="g_atomic_pointer_get ()"><code class="function">g_atomic_pointer_get()</code></a>
for read outs. They provide the neccessary synchonization mechanisms
like memory barriers to access memory locations concurrently.
</p>
</div>
<p>
</p>
<p>
</p>
<div class="note" style="margin-left: 0.5in; margin-right: 0.5in;">
<h3 class="title">Note</h3>
<p>If you are using those functions for anything apart from
simple reference counting, you should really be aware of the implications
of doing that. There are literally thousands of ways to shoot yourself
in the foot. So if in doubt, use a <a class="link" href="glib-Threads.html#GMutex" title="GMutex"><span class="type">GMutex</span></a>. If you don't know, what
memory barriers are, do not use anything but <a class="link" href="glib-Atomic-Operations.html#g-atomic-int-inc" title="g_atomic_int_inc ()"><code class="function">g_atomic_int_inc()</code></a> and
<a class="link" href="glib-Atomic-Operations.html#g-atomic-int-dec-and-test" title="g_atomic_int_dec_and_test ()"><code class="function">g_atomic_int_dec_and_test()</code></a>.
</p>
</div>
<p>
</p>
<p>
</p>
<div class="note" style="margin-left: 0.5in; margin-right: 0.5in;">
<h3 class="title">Note</h3>
<p>It is not safe to set an integer or pointer just by assigning
to it, when it is concurrently accessed by other threads with the following
functions. Use <a class="link" href="glib-Atomic-Operations.html#g-atomic-int-compare-and-exchange" title="g_atomic_int_compare_and_exchange ()"><code class="function">g_atomic_int_compare_and_exchange()</code></a> or
<a class="link" href="glib-Atomic-Operations.html#g-atomic-pointer-compare-and-exchange" title="g_atomic_pointer_compare_and_exchange ()"><code class="function">g_atomic_pointer_compare_and_exchange()</code></a> respectively.
</p>
</div>
<p>
</p>
</div>
<div class="refsect1">
<a name="glib-Atomic-Operations.details"></a><h2>Details</h2>
<div class="refsect2">
<a name="g-atomic-int-get"></a><h3>g_atomic_int_get ()</h3>
<pre class="programlisting"><a class="link" href="glib-Basic-Types.html#gint" title="gint"><span class="returnvalue">gint</span></a>                g_atomic_int_get                    (<em class="parameter"><code>volatile <a class="link" href="glib-Basic-Types.html#gint" title="gint"><span class="type">gint</span></a> G_GNUC_MAY_ALIAS *atomic</code></em>);</pre>
<p>
Reads the value of the integer pointed to by <em class="parameter"><code>atomic</code></em>.
Also acts as a memory barrier.
</p>
<div class="variablelist"><table border="0">
<col align="left" valign="top">
<tbody>
<tr>
<td><p><span class="term"><em class="parameter"><code>atomic</code></em> :</span></p></td>
<td>a pointer to an integer</td>
</tr>
<tr>
<td><p><span class="term"><span class="emphasis"><em>Returns</em></span> :</span></p></td>
<td>the value of *<em class="parameter"><code>atomic</code></em>
</td>
</tr>
</tbody>
</table></div>
<p class="since">Since 2.4</p>
</div>
<hr>
<div class="refsect2">
<a name="g-atomic-int-set"></a><h3>g_atomic_int_set ()</h3>
<pre class="programlisting"><span class="returnvalue">void</span>                g_atomic_int_set                    (<em class="parameter"><code>volatile <a class="link" href="glib-Basic-Types.html#gint" title="gint"><span class="type">gint</span></a> G_GNUC_MAY_ALIAS *atomic</code></em>,
                                                         <em class="parameter"><code><a class="link" href="glib-Basic-Types.html#gint" title="gint"><span class="type">gint</span></a> newval</code></em>);</pre>
<p>
Sets the value of the integer pointed to by <em class="parameter"><code>atomic</code></em>.
Also acts as a memory barrier.
</p>
<div class="variablelist"><table border="0">
<col align="left" valign="top">
<tbody>
<tr>
<td><p><span class="term"><em class="parameter"><code>atomic</code></em> :</span></p></td>
<td>a pointer to an integer</td>
</tr>
<tr>
<td><p><span class="term"><em class="parameter"><code>newval</code></em> :</span></p></td>
<td>the new value</td>
</tr>
</tbody>
</table></div>
<p class="since">Since 2.10</p>
</div>
<hr>
<div class="refsect2">
<a name="g-atomic-int-add"></a><h3>g_atomic_int_add ()</h3>
<pre class="programlisting"><span class="returnvalue">void</span>                g_atomic_int_add                    (<em class="parameter"><code>volatile <a class="link" href="glib-Basic-Types.html#gint" title="gint"><span class="type">gint</span></a> G_GNUC_MAY_ALIAS *atomic</code></em>,
                                                         <em class="parameter"><code><a class="link" href="glib-Basic-Types.html#gint" title="gint"><span class="type">gint</span></a> val</code></em>);</pre>
<p>
Atomically adds <em class="parameter"><code>val</code></em> to the integer pointed to by <em class="parameter"><code>atomic</code></em>.
Also acts as a memory barrier.
</p>
<div class="variablelist"><table border="0">
<col align="left" valign="top">
<tbody>
<tr>
<td><p><span class="term"><em class="parameter"><code>atomic</code></em> :</span></p></td>
<td>a pointer to an integer</td>
</tr>
<tr>
<td><p><span class="term"><em class="parameter"><code>val</code></em> :</span></p></td>
<td>the value to add to *<em class="parameter"><code>atomic</code></em>
</td>
</tr>
</tbody>
</table></div>
<p class="since">Since 2.4</p>
</div>
<hr>
<div class="refsect2">
<a name="g-atomic-int-exchange-and-add"></a><h3>g_atomic_int_exchange_and_add ()</h3>
<pre class="programlisting"><a class="link" href="glib-Basic-Types.html#gint" title="gint"><span class="returnvalue">gint</span></a>                g_atomic_int_exchange_and_add       (<em class="parameter"><code>volatile <a class="link" href="glib-Basic-Types.html#gint" title="gint"><span class="type">gint</span></a> G_GNUC_MAY_ALIAS *atomic</code></em>,
                                                         <em class="parameter"><code><a class="link" href="glib-Basic-Types.html#gint" title="gint"><span class="type">gint</span></a> val</code></em>);</pre>
<p>
Atomically adds <em class="parameter"><code>val</code></em> to the integer pointed to by <em class="parameter"><code>atomic</code></em>.
It returns the value of *<em class="parameter"><code>atomic</code></em> just before the addition
took place. Also acts as a memory barrier.
</p>
<div class="variablelist"><table border="0">
<col align="left" valign="top">
<tbody>
<tr>
<td><p><span class="term"><em class="parameter"><code>atomic</code></em> :</span></p></td>
<td>a pointer to an integer</td>
</tr>
<tr>
<td><p><span class="term"><em class="parameter"><code>val</code></em> :</span></p></td>
<td>the value to add to *<em class="parameter"><code>atomic</code></em>
</td>
</tr>
<tr>
<td><p><span class="term"><span class="emphasis"><em>Returns</em></span> :</span></p></td>
<td>the value of *<em class="parameter"><code>atomic</code></em> before the addition.</td>
</tr>
</tbody>
</table></div>
<p class="since">Since 2.4</p>
</div>
<hr>
<div class="refsect2">
<a name="g-atomic-int-compare-and-exchange"></a><h3>g_atomic_int_compare_and_exchange ()</h3>
<pre class="programlisting"><a class="link" href="glib-Basic-Types.html#gboolean" title="gboolean"><span class="returnvalue">gboolean</span></a>            g_atomic_int_compare_and_exchange   (<em class="parameter"><code>volatile <a class="link" href="glib-Basic-Types.html#gint" title="gint"><span class="type">gint</span></a> G_GNUC_MAY_ALIAS *atomic</code></em>,
                                                         <em class="parameter"><code><a class="link" href="glib-Basic-Types.html#gint" title="gint"><span class="type">gint</span></a> oldval</code></em>,
                                                         <em class="parameter"><code><a class="link" href="glib-Basic-Types.html#gint" title="gint"><span class="type">gint</span></a> newval</code></em>);</pre>
<p>
Compares <em class="parameter"><code>oldval</code></em> with the integer pointed to by <em class="parameter"><code>atomic</code></em> and
if they are equal, atomically exchanges *<em class="parameter"><code>atomic</code></em> with <em class="parameter"><code>newval</code></em>.
Also acts as a memory barrier.
</p>
<div class="variablelist"><table border="0">
<col align="left" valign="top">
<tbody>
<tr>
<td><p><span class="term"><em class="parameter"><code>atomic</code></em> :</span></p></td>
<td>a pointer to an integer</td>
</tr>
<tr>
<td><p><span class="term"><em class="parameter"><code>oldval</code></em> :</span></p></td>
<td>the assumed old value of *<em class="parameter"><code>atomic</code></em>
</td>
</tr>
<tr>
<td><p><span class="term"><em class="parameter"><code>newval</code></em> :</span></p></td>
<td>the new value of *<em class="parameter"><code>atomic</code></em>
</td>
</tr>
<tr>
<td><p><span class="term"><span class="emphasis"><em>Returns</em></span> :</span></p></td>
<td>
<a class="link" href="glib-Standard-Macros.html#TRUE:CAPS" title="TRUE"><code class="literal">TRUE</code></a>, if *<em class="parameter"><code>atomic</code></em> was equal <em class="parameter"><code>oldval</code></em>. <a class="link" href="glib-Standard-Macros.html#FALSE:CAPS" title="FALSE"><code class="literal">FALSE</code></a> otherwise.</td>
</tr>
</tbody>
</table></div>
<p class="since">Since 2.4</p>
</div>
<hr>
<div class="refsect2">
<a name="g-atomic-pointer-get"></a><h3>g_atomic_pointer_get ()</h3>
<pre class="programlisting"><a class="link" href="glib-Basic-Types.html#gpointer" title="gpointer"><span class="returnvalue">gpointer</span></a>            g_atomic_pointer_get                (<em class="parameter"><code>volatile <a class="link" href="glib-Basic-Types.html#gpointer" title="gpointer"><span class="type">gpointer</span></a> G_GNUC_MAY_ALIAS *atomic</code></em>);</pre>
<p>
Reads the value of the pointer pointed to by <em class="parameter"><code>atomic</code></em>.
Also acts as a memory barrier.
</p>
<div class="variablelist"><table border="0">
<col align="left" valign="top">
<tbody>
<tr>
<td><p><span class="term"><em class="parameter"><code>atomic</code></em> :</span></p></td>
<td>a pointer to a <a class="link" href="glib-Basic-Types.html#gpointer" title="gpointer"><span class="type">gpointer</span></a>.</td>
</tr>
<tr>
<td><p><span class="term"><span class="emphasis"><em>Returns</em></span> :</span></p></td>
<td>the value to add to *<em class="parameter"><code>atomic</code></em>.</td>
</tr>
</tbody>
</table></div>
<p class="since">Since 2.4</p>
</div>
<hr>
<div class="refsect2">
<a name="g-atomic-pointer-set"></a><h3>g_atomic_pointer_set ()</h3>
<pre class="programlisting"><span class="returnvalue">void</span>                g_atomic_pointer_set                (<em class="parameter"><code>volatile <a class="link" href="glib-Basic-Types.html#gpointer" title="gpointer"><span class="type">gpointer</span></a> G_GNUC_MAY_ALIAS *atomic</code></em>,
                                                         <em class="parameter"><code><a class="link" href="glib-Basic-Types.html#gpointer" title="gpointer"><span class="type">gpointer</span></a> newval</code></em>);</pre>
<p>
Sets the value of the pointer pointed to by <em class="parameter"><code>atomic</code></em>.
Also acts as a memory barrier.
</p>
<div class="variablelist"><table border="0">
<col align="left" valign="top">
<tbody>
<tr>
<td><p><span class="term"><em class="parameter"><code>atomic</code></em> :</span></p></td>
<td>a pointer to a <a class="link" href="glib-Basic-Types.html#gpointer" title="gpointer"><span class="type">gpointer</span></a>
</td>
</tr>
<tr>
<td><p><span class="term"><em class="parameter"><code>newval</code></em> :</span></p></td>
<td>the new value</td>
</tr>
</tbody>
</table></div>
<p class="since">Since 2.10</p>
</div>
<hr>
<div class="refsect2">
<a name="g-atomic-pointer-compare-and-exchange"></a><h3>g_atomic_pointer_compare_and_exchange ()</h3>
<pre class="programlisting"><a class="link" href="glib-Basic-Types.html#gboolean" title="gboolean"><span class="returnvalue">gboolean</span></a>            g_atomic_pointer_compare_and_exchange
                                                        (<em class="parameter"><code>volatile <a class="link" href="glib-Basic-Types.html#gpointer" title="gpointer"><span class="type">gpointer</span></a> G_GNUC_MAY_ALIAS *atomic</code></em>,
                                                         <em class="parameter"><code><a class="link" href="glib-Basic-Types.html#gpointer" title="gpointer"><span class="type">gpointer</span></a> oldval</code></em>,
                                                         <em class="parameter"><code><a class="link" href="glib-Basic-Types.html#gpointer" title="gpointer"><span class="type">gpointer</span></a> newval</code></em>);</pre>
<p>
Compares <em class="parameter"><code>oldval</code></em> with the pointer pointed to by <em class="parameter"><code>atomic</code></em> and
if they are equal, atomically exchanges *<em class="parameter"><code>atomic</code></em> with <em class="parameter"><code>newval</code></em>.
Also acts as a memory barrier.
</p>
<div class="variablelist"><table border="0">
<col align="left" valign="top">
<tbody>
<tr>
<td><p><span class="term"><em class="parameter"><code>atomic</code></em> :</span></p></td>
<td>a pointer to a <a class="link" href="glib-Basic-Types.html#gpointer" title="gpointer"><span class="type">gpointer</span></a>
</td>
</tr>
<tr>
<td><p><span class="term"><em class="parameter"><code>oldval</code></em> :</span></p></td>
<td>the assumed old value of *<em class="parameter"><code>atomic</code></em>
</td>
</tr>
<tr>
<td><p><span class="term"><em class="parameter"><code>newval</code></em> :</span></p></td>
<td>the new value of *<em class="parameter"><code>atomic</code></em>
</td>
</tr>
<tr>
<td><p><span class="term"><span class="emphasis"><em>Returns</em></span> :</span></p></td>
<td>
<a class="link" href="glib-Standard-Macros.html#TRUE:CAPS" title="TRUE"><code class="literal">TRUE</code></a>, if *<em class="parameter"><code>atomic</code></em> was equal <em class="parameter"><code>oldval</code></em>. <a class="link" href="glib-Standard-Macros.html#FALSE:CAPS" title="FALSE"><code class="literal">FALSE</code></a> otherwise.</td>
</tr>
</tbody>
</table></div>
<p class="since">Since 2.4</p>
</div>
<hr>
<div class="refsect2">
<a name="g-atomic-int-inc"></a><h3>g_atomic_int_inc ()</h3>
<pre class="programlisting"><span class="returnvalue">void</span>                g_atomic_int_inc                    (<em class="parameter"><code><a class="link" href="glib-Basic-Types.html#gint" title="gint"><span class="type">gint</span></a> *atomic</code></em>);</pre>
<p>
Atomically increments the integer pointed to by <em class="parameter"><code>atomic</code></em> by 1.
</p>
<div class="variablelist"><table border="0">
<col align="left" valign="top">
<tbody><tr>
<td><p><span class="term"><em class="parameter"><code>atomic</code></em> :</span></p></td>
<td>a pointer to an integer.</td>
</tr></tbody>
</table></div>
<p class="since">Since 2.4</p>
</div>
<hr>
<div class="refsect2">
<a name="g-atomic-int-dec-and-test"></a><h3>g_atomic_int_dec_and_test ()</h3>
<pre class="programlisting"><a class="link" href="glib-Basic-Types.html#gboolean" title="gboolean"><span class="returnvalue">gboolean</span></a>            g_atomic_int_dec_and_test           (<em class="parameter"><code><a class="link" href="glib-Basic-Types.html#gint" title="gint"><span class="type">gint</span></a> *atomic</code></em>);</pre>
<p>
Atomically decrements the integer pointed to by <em class="parameter"><code>atomic</code></em> by 1.
</p>
<div class="variablelist"><table border="0">
<col align="left" valign="top">
<tbody>
<tr>
<td><p><span class="term"><em class="parameter"><code>atomic</code></em> :</span></p></td>
<td>a pointer to an integer</td>
</tr>
<tr>
<td><p><span class="term"><span class="emphasis"><em>Returns</em></span> :</span></p></td>
<td>
<a class="link" href="glib-Standard-Macros.html#TRUE:CAPS" title="TRUE"><code class="literal">TRUE</code></a> if the integer pointed to by <em class="parameter"><code>atomic</code></em> is 0
after decrementing it</td>
</tr>
</tbody>
</table></div>
<p class="since">Since 2.4</p>
</div>
</div>
<div class="refsect1">
<a name="glib-Atomic-Operations.see-also"></a><h2>See Also</h2>
<a class="link" href="glib-Threads.html#GMutex" title="GMutex"><span class="type">GMutex</span></a>
</div>
</div>
<div class="footer">
<hr>
          Generated by GTK-Doc V1.17</div>
</body>
</html>